package com.exam.stream;

import com.sun.tools.attach.AttachNotSupportedException;
import com.sun.tools.attach.VirtualMachine;
import com.sun.tools.attach.VirtualMachineDescriptor;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

//集合与数组互换
public class test01 {
    public static void main(String[] args) throws Exception {
        test01();

        //获取当前系统中所有 运行中的 虚拟机
        List<VirtualMachineDescriptor> list = VirtualMachine.list();
        for (VirtualMachineDescriptor vm : list) {
            if (vm.displayName().endsWith("com.exam.stream.test01")) {
                VirtualMachine virtualMachine = VirtualMachine.attach(vm.id());
                virtualMachine.loadAgent("D:/agent-demo.jar");
                virtualMachine.detach();
            }
        }
    }

    private static void test01() {
        int[] arr = {1,2,3};
        List<int[]> list2 = Stream.of(arr).collect(Collectors.toList());
        List<Integer> list = Arrays.stream(arr).boxed().collect(Collectors.toList());
        /*Integer[] arrs=new Integer[list.size()];
        list.toArray(arrs);*/
        Integer[] ints = list.stream().toArray(Integer[]::new);
        String[] strs={"1q","2f","c"};
        List<String> list1 = Arrays.stream(strs).collect(Collectors.toList());
        String[] strings = list1.stream().toArray(String[]::new);
        System.out.println("----代理测试----");
    }
}
